package cn.liziguo.tank.buff;

import cn.liziguo.tank.config.GameConfig;
import cn.liziguo.tank.script.BaseTankComponent;
import com.almasb.fxgl.dsl.components.Effect;
import com.almasb.fxgl.entity.Entity;
import javafx.util.Duration;
import org.jetbrains.annotations.NotNull;

/**
 * @author Liziguo
 * @date 2022/7/12 15:27
 */
public class SpeedingEffect extends Effect {

    private BaseTankComponent baseTankComponent;

    public SpeedingEffect() {
        super(Duration.INDEFINITE);
    }

    @Override
    public void onEnd(@NotNull Entity entity) {
        baseTankComponent.speed -= GameConfig.SPEEDING_NUM;
    }

    @Override
    public void onStart(@NotNull Entity entity) {
        baseTankComponent = BaseTankComponent.getTankComponent(entity);
        baseTankComponent.speed += GameConfig.SPEEDING_NUM;
    }
}
